<?php
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

include "database.php";
include "global.php";
function showAll(){
    $sql = "SELECT * FROM product_type ORDER BY id";
    $query = mysql_query($sql);


    return $query;
}

function addProduct($input){
    $input = validate($input);
    $sql="INSERT INTO product_type(name) VALUES('".$input."')";
    $query = mysql_query($sql);
    if(!$query)
        echo "query error";
}

function query_one($id){
    $sql="SELECT name FROM product_type WHERE id=".$id;
    $query = mysql_query($sql);
    $output = mysql_fetch_array($query);
    return $output['name'];
}

function editProduct($id,$name){
    $sql="UPDATE product_type SET name='".$name."' WHERE id=".$id;
    if(!mysql_query($sql))
        echo "update error";
}
?>
